package com.soft.javase.day15.annotations;

import org.junit.Test;

import java.lang.reflect.Method;
import java.util.Arrays;

/**
 * @author yzg
 * @desc TODO
 * @date 2025/5/27
 */
public class AnnotationTest {
    @Test
    public void annotationTest() throws NoSuchMethodException {
        Class<BookStore> bookStoreClass = BookStore.class;
        Method purchase = bookStoreClass.getDeclaredMethod("purchase");
        if(purchase.isAnnotationPresent(Book.class)){
            Book annotation = purchase.getDeclaredAnnotation(Book.class);
            System.out.println("书名"+annotation.value());
            System.out.println("价格"+annotation.price());
            System.out.println("作者"+ Arrays.toString(annotation.authors()));
        }else {
            System.out.println("purchase方法上没有Book注解");
        }
    }
}
